<template>
  <div class="user_feedback">
    <div class="feedback_cont">
      <div class="feedback_list">
        <div>本次活动用户评论（共{{ commentList.length }}条）：</div>
        <div class="line"></div>
        <div class="item_feedback" v-for="(item, index) in commentList" :key="index">
          <img :src="item.avatar" alt="" class="user_img" />

          <div>
            <div class="user_name">{{ item.user_name }}</div>
            <div class="user_comment">
              {{ item.content }}
            </div>
            <div class="comment_time">{{ convertTimestampToDateTime(item.time) }}</div>
          </div>
        </div>
      </div>
      <div class="no_data_txt">-- 暂无更多评论 --</div>
    </div>
    <div class="footer_box">
      <input type="text" placeholder="参与回复" v-model="content" />
      <div class="send_btn" @click="toComment">发送</div>
    </div>
  </div>
</template>

<script>
import { convertTimestampToDateTime } from "@/utils/time";
import { queryCommentList, submitComment } from '@/api/funcation/groupActivity'
export default {
  props: {
    taskId: Number,
    id: Number
  },
  data() {
    return {
      pageSize: 10,
      page: 1,
      content: "",
      commentList: []
    }
  },
  created() {
    this.getCommentList()
  },
  methods: {
    convertTimestampToDateTime,
    //发送评论
    async toComment() {
      let par = {
        id: this.taskId,
        content: this.content
      }
      let res = await submitComment(par)
      if (res.code == 200) {
        this.$toast.success("评论成功！");
        this.getCommentList()
      }
      this.content = ''
    },
    async getCommentList() {
      let par = {
        id: this.taskId,
        pageSize: this.pageSize,
        page: this.page
      }
      let res = await queryCommentList(par)
      if (res.code == 200) {
        this.commentList = res.data.data
      }
    }
  }
}
</script>

<style lang="less" scoped>
.feedback_list {
  background: #ffffff;
  border-radius: 6.67px;
  padding: 14px 10px 23px 10px;
  color: #333333;
  margin-top: 10px;
}

.feedback_cont {
  padding: 0 10px;
}

.line {
  border-bottom: 0.33px solid #dddddd;
  margin: 13.33px 0 20px;
}

.item_feedback {
  display: flex;
  margin-bottom: 33px;

  &:last-child {
    margin: 0;
  }
}

.user_img {
  width: 40px;
  height: 40px;
  margin-right: 14.33px;
  border-radius: 50%;
}

.user_name {
  color: #00aeff;
  font-size: 14.67px;
  line-height: 14.67px;
}

.user_comment {
  line-height: 24px;
  font-size: 13.33px;
  margin: 15.3px 0 16.67px;
}

.comment_time {
  color: #333333;
  opacity: 0.5;
  font-size: 12px;
  line-height: 12px;
}

.no_data_txt {
  color: #555555;
  font-size: 10.67px;
  margin: 33px 0 93px;
  text-align: center;
}

.footer_box {
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60px;
  background: #ffffff;
}

input {
  width: 260px;
  height: 36.67px;
  background: rgba(247, 247, 247, 0.97);
  border-radius: 6.67px;
  padding: 0 10px;
  border: 0;
}

.send_btn {
  width: 66.67px;
  height: 36.67px;
  background: linear-gradient(0deg, #ffffff -20%, rgba(255, 255, 255, 0) 20%),
    #00aeff;
  border-radius: 6.67px;
  text-align: center;
  color: #ffffff;
  font-size: 14px;
  line-height: 36.67px;
  margin-left: 6.67px;
}
</style>